﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.IO;
using System.Net;
using ASPItalia.ModelVirtualCasting.WPF.Common.Helpers;
using System.ComponentModel;
using System.Diagnostics;

namespace ASPItalia.ModelVirtualCasting.WPF.Models
{
    public abstract class Multimedia : INotifyPropertyChanged
    {

        protected Multimedia()
        {

        }

        public string FileName { get; set; }

        #region INotifyPropertyChanged Members

        private PropertyChangedEventHandler _propertyChanged;

        event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged
        {
            add { _propertyChanged += value; }
            remove { _propertyChanged -= value; }
        }

        protected virtual void OnPropertyChanged(string propertyName)
        {
            OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
        }

        protected virtual void OnPropertyChanged<T>(string propertyName, T oldValue, T newValue)
        {
            OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
        }

        protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
        {
            this.VerifyPropertyName(e.PropertyName);

            if (_propertyChanged != null)
                _propertyChanged(this, e);
        }

        [Conditional("DEBUG")]
        [DebuggerStepThrough]
        protected void VerifyPropertyName(string propertyName)
        {
            if (TypeDescriptor.GetProperties(this)[propertyName] == null)
            {
                Debug.Fail("Invalid property name: " + propertyName);
            }
        }
        #endregion
    }

}
